| Conditions | 2 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | /* |
||
| 10 | |||
| 11 | /** |
||
| 12 | * This function is the only export of this module, and can be used to extend custom builds of `decimal.js`. |
||
| 13 | * |
||
| 14 | * @param decimalClass Decimal class/constructor to be extended. |
||
| 15 | * @returns The augmented class/constructor. |
||
| 16 | */ |
||
| 17 | 1 | export function extend(decimalClass: Partial<Decimal.Constructor>) { |
|
| 18 | 4 | if (!decimalClass || typeof decimalClass.isDecimal !== "function") { |
|
| 19 | 1 | throw new TypeError("Invalid argument Decimal argument."); |
|
| 20 | } |
||
| 21 | |||
| 22 | 1 | globalThis.__Decimal__Class__Global__ = decimalClass as Decimal.Constructor; |
|
| 23 | 1 | require("."); |
|
| 24 | 1 | delete globalThis.__Decimal__Class__Global__; |
|
| 25 | 1 | return decimalClass as typeof Decimal; |
|
| 26 | } |
||
| 28 |